package cn.edu.xmu.restfuldemo.model.VO;

import cn.edu.xmu.restfuldemo.model.BO.Goods;
import cn.edu.xmu.restfuldemo.model.BO.Product;
import cn.edu.xmu.restfuldemo.model.VoObject;
import lombok.*;

import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;

/**
 * @author RenJieZheng
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ProductRetVo implements VoObject, Serializable {
    private Long id;
    private Long goodsId;
    private String productSn;
    private String name;
    private Long originalPrice;
    private Long weight;
    private String imageUrl;
    private Byte state;
    private String detail;
    private Byte disabled;
    private Long price;
    private Long inventory;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;
    private Goods goods;

    public ProductRetVo(Product product,Goods goods){
        this.id = product.getId();
        this.goodsId = product.getGoodsId();
        this.productSn = product.getProductSn();
        this.name = product.getName();
        this.originalPrice = product.getOriginalPrice();
        this.weight = product.getWeight();
        this.imageUrl = product.getImageUrl();
        this.state = product.getState();
        this.detail = product.getDetail();
        this.disabled = product.getDisabled();
        this.price = null;
        this.inventory = null;
        this.gmtCreate = product.getGmtCreate();
        this.gmtModified = product.getGmtModified();
        this.goods = goods;
    }

    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() {
        return this;
    }
}
